import React from 'react';
import { WeaTop, WeaTab, WeaNewScroll, WeaRightMenu } from 'ecCom';
import { observer, inject } from 'mobx-react';
import Comment from '../dialog/index';
import GovernMind from '../governMind/index';
import GovernTaskList from './GovernTaskList';
import { toJS } from 'mobx';

@inject("proinfoStore")
@observer
export default class TaskAccCard extends React.Component {

    constructor(props) {
        super(props);
    }

    render() {
        const { store } = this.props;
        return (
            <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@xl276e`}
                datas={store.getRightMenu()}
            >
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@oehm8i`}
                    title={store.title}
                    icon={<i className="icon-coms-government" />}
                    iconBgcolor='#f14a2d'
                    showDropIcon={true}
                    buttons={store.getButtons()}
                    dropMenuDatas={store.getRightMenu()}
                >
                    <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@cgq1mb`}
                        datas={toJS(store.getTabData())}
                        keyParam="viewcondition"  //主键
                        countParam="groupid" //数量
                        selectedKey={store.selectTabKey}
                        onChange={v => { store.tabOnChange(v) }}
                    />
                    <div>
                        {this.getTabs()}
                    </div>
                </WeaTop>
            </WeaRightMenu>
        )
    }


    getTabs = () => {
        const { proinfoStore, store } = this.props;
        const { type, governMindStore, governAnalysisStore } = proinfoStore;
        let { currentKey, isSetCurrentKey, selectTabKey, firstComing, mindComing } = store;
        let re;
        if (isSetCurrentKey) {
            if (selectTabKey === "0") {//督办详情
                re = <Comment ecId={`${this && this.props && this.props.ecId || ''}_Comment@aceaij`} id={currentKey} type={type} firstComing={firstComing} taskAccount={true}></Comment>;
            } else if (selectTabKey === "1") {//思维导图
                re = <GovernMind ecId={`${this && this.props && this.props.ecId || ''}_GovernMind@p197gf`} id={currentKey} proinfoStore={proinfoStore} governMindStore={governMindStore} governAnalysisStore={governAnalysisStore} mindComing={mindComing} />
            } else if (selectTabKey === "2") {//任务列表
                re = <GovernTaskList ecId={`${this && this.props && this.props.ecId || ''}_GovernTaskList@tw1mt4`} taskAccountStore={store} id={currentKey} taskKey={Math.random()} hasTaskRight={store.hasTaskRight} />
            }

            return re;
        }
    }

}